import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tiktokadult/assets_tool/images.dart';
import 'package:tiktokadult/hj_page/community_business/hot_up_user/hot_up_list_page.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';
import 'package:tiktokadult/routers/jump_router.dart';

import '../../../hj_model/message/search_user_obj.dart';
import '../../../tools_base/widget/net_image_widget.dart';

class HotUpUserView extends StatelessWidget {
  List<HotBloggerEntity>? hotUpList;

  HotUpUserView({this.hotUpList});

  @override
  Widget build(BuildContext context) {
    if (hotUpList?.isNotEmpty != true) return SizedBox();
    return Container(
      padding: EdgeInsets.fromLTRB(16, 0, 0, 12),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          InkWell(
            onTap: () {
              Get.to(HotUpListPage(), preventDuplicates: false);
            },
            child: Row(
              children: [
                Text(
                  "热门博主",
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 18,
                    fontWeight: FontWeight.w600,
                  ),
                ),
                Spacer(),
                Image.asset("arrow_right_grey.webp".commonImgPath, width: 18),
                16.sizeBoxW,
              ],
            ),
          ),
          10.sizeBoxH,
          SizedBox(
            height: 86,
            child: ListView.builder(
              itemCount: hotUpList?.length ?? 0,
              scrollDirection: Axis.horizontal,
              padding: EdgeInsets.zero,
              itemBuilder: (context, index) {
                HotBloggerEntity model = hotUpList![index];
                return Container(
                  margin: EdgeInsets.only(right: 8),
                  width: 60,
                  child: InkWell(
                    onTap: () {
                      pushToPersonCenter(model.uid);
                    },
                    child: Column(
                      children: [
                        NetworkImageLoader(
                          imageUrl: model.portrait ?? '',
                          width: 60,
                          height: 60,
                          loadWidth: 60 * 3,
                          borderRadius: 30,
                        ),
                        Spacer(),
                        Text(
                          model.name ?? "",
                          maxLines: 1,
                          style: TextStyle(
                            fontSize: 12,
                            color: Colors.white,
                          ),
                        )
                      ],
                    ),
                  ),
                );
              },
            ),
          ),
          16.sizeBoxH,
          Container(
            margin: EdgeInsets.only(right: 16),
            height: 1,
            color: Colors.white.withOpacity(.1),
          ),
        ],
      ),
    );
  }
}
